import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
public class Example25 {
    public static void main(String[] args) {
        LocalDate now = LocalDate.now();
        LocalDate of = LocalDate.of(2015,12,12);
        System.out.println("1.LocalDate的获取及格式化的相关方法--------");
        System.out.println("从LocalDate实例获取当前的年份："+now.getYear());
        System.out.println("从LocalDate实例获取当前的月份："+now.getMonthValue());
        System.out.println("从LocalDate实例获取当前是本月的第几天："+now.getDayOfMonth());
        System.out.println("将获取到的LocalDate实例格式化后：" +now.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
        System.out.println("2.LocalDate判断的相关方法--------");
        System.out.println("判断日期of是否在Now之前："+of.isBefore(now));
        System.out.println("判断日期of是否在Now之后："+of.isAfter(now));
        System.out.println("判断日期of和Now是否相等："+of.equals(now));
        System.out.println("判断日期of是否是闰年："+of.isLeapYear());
        System.out.println("3.LocalDate解析以及加减的相关操作--------");
        String dateStr="2020-02-01";
        System.out.println("LocalDate把日期字符串解析成日期对象的结果："
                +LocalDate.parse(dateStr));
        System.out.println("LocalDate年份加1结果："
                +now.plusYears(1));
        System.out.println("LocalDate天数减去10："
                +now.minusDays(10));
        System.out.println("LocalDate年份设置为2014："
                +now.withYear(2014));

    }
}
